3.473 \(\int \frac{1}{(a+b \tan (c+d x))^2} \, dx\)

Optimal. Leaf size=82 \[ -\frac{b}{d \left (a^2+b^2\right ) (a+b \tan (c+d x))}+\frac{2 a b \log (a \cos (c+d x)+b \sin (c+d x))}{d \left (a^2+b^2\right )^2}+\frac{x \left (a^2-b^2\right )}{\left (a^2+b^2\right )^2} \]

[Out]

((a^2 - b^2)*x)/(a^2 + b^2)^2 + (2*a*b*Log[a*Cos[c + d*x] + b*Sin[c + d*x]])/((a^2 + b^2)^2*d) - b/((a^2 + b^2
)*d*(a + b*Tan[c + d*x]))

________________________________________________________________________________________

Rubi [A]  time = 0.0810732, antiderivative size = 82, normalized size of antiderivative = 1., number of steps used = 3, number of rules used = 3, integrand size = 12, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.25, Rules used = {3483, 3531, 3530} \[ -\frac{b}{d \left (a^2+b^2\right ) (a+b \tan (c+d x))}+\frac{2 a b \log (a \cos (c+d x)+b \sin (c+d x))}{d \left (a^2+b^2\right )^2}+\frac{x \left (a^2-b^2\right )}{\left (a^2+b^2\right )^2} \]

Antiderivative was successfully verified.

[In]

Int[(a + b*Tan[c + d*x])^(-2),x]

[Out]

((a^2 - b^2)*x)/(a^2 + b^2)^2 + (2*a*b*Log[a*Cos[c + d*x] + b*Sin[c + d*x]])/((a^2 + b^2)^2*d) - b/((a^2 + b^2
)*d*(a + b*Tan[c + d*x]))

Rule 3483

Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> Simp[(b*(a + b*Tan[c + d*x])^(n + 1))/(d*(n + 1)
*(a^2 + b^2)), x] + Dist[1/(a^2 + b^2), Int[(a - b*Tan[c + d*x])*(a + b*Tan[c + d*x])^(n + 1), x], x] /; FreeQ
[{a, b, c, d}, x] && NeQ[a^2 + b^2, 0] && LtQ[n, -1]

Rule 3531

Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[((a*c +
 b*d)*x)/(a^2 + b^2), x] + Dist[(b*c - a*d)/(a^2 + b^2), Int[(b - a*Tan[e + f*x])/(a + b*Tan[e + f*x]), x], x]
 /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[a*c + b*d, 0]

Rule 3530

Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(c*Log[Re
moveContent[a*Cos[e + f*x] + b*Sin[e + f*x], x]])/(b*f), x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d,
0] && NeQ[a^2 + b^2, 0] && EqQ[a*c + b*d, 0]

Rubi steps

\begin{align*} \int \frac{1}{(a+b \tan (c+d x))^2} \, dx &=-\frac{b}{\left (a^2+b^2\right ) d (a+b \tan (c+d x))}+\frac{\int \frac{a-b \tan (c+d x)}{a+b \tan (c+d x)} \, dx}{a^2+b^2}\\ &=\frac{\left (a^2-b^2\right ) x}{\left (a^2+b^2\right )^2}-\frac{b}{\left (a^2+b^2\right ) d (a+b \tan (c+d x))}+\frac{(2 a b) \int \frac{b-a \tan (c+d x)}{a+b \tan (c+d x)} \, dx}{\left (a^2+b^2\right )^2}\\ &=\frac{\left (a^2-b^2\right ) x}{\left (a^2+b^2\right )^2}+\frac{2 a b \log (a \cos (c+d x)+b \sin (c+d x))}{\left (a^2+b^2\right )^2 d}-\frac{b}{\left (a^2+b^2\right ) d (a+b \tan (c+d x))}\\ \end{align*}

Mathematica [C]  time = 1.18487, size = 106, normalized size = 1.29 \[ \frac{\frac{2 b \left (2 a \log (a+b \tan (c+d x))-\frac{a^2+b^2}{a+b \tan (c+d x)}\right )}{\left (a^2+b^2\right )^2}-\frac{i \log (-\tan (c+d x)+i)}{(a+i b)^2}+\frac{i \log (\tan (c+d x)+i)}{(a-i b)^2}}{2 d} \]

Antiderivative was successfully verified.

[In]

Integrate[(a + b*Tan[c + d*x])^(-2),x]

[Out]

(((-I)*Log[I - Tan[c + d*x]])/(a + I*b)^2 + (I*Log[I + Tan[c + d*x]])/(a - I*b)^2 + (2*b*(2*a*Log[a + b*Tan[c
+ d*x]] - (a^2 + b^2)/(a + b*Tan[c + d*x])))/(a^2 + b^2)^2)/(2*d)

________________________________________________________________________________________

Maple [A]  time = 0.023, size = 130, normalized size = 1.6 \begin{align*}{\frac{\arctan \left ( \tan \left ( dx+c \right ) \right ){a}^{2}}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-{\frac{\arctan \left ( \tan \left ( dx+c \right ) \right ){b}^{2}}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-{\frac{ab\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ) }{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-{\frac{b}{ \left ({a}^{2}+{b}^{2} \right ) d \left ( a+b\tan \left ( dx+c \right ) \right ) }}+2\,{\frac{ab\ln \left ( a+b\tan \left ( dx+c \right ) \right ) }{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(1/(a+b*tan(d*x+c))^2,x)

[Out]

1/d/(a^2+b^2)^2*arctan(tan(d*x+c))*a^2-1/d/(a^2+b^2)^2*arctan(tan(d*x+c))*b^2-1/d/(a^2+b^2)^2*a*b*ln(1+tan(d*x
+c)^2)-b/(a^2+b^2)/d/(a+b*tan(d*x+c))+2/d*b*a/(a^2+b^2)^2*ln(a+b*tan(d*x+c))

________________________________________________________________________________________

Maxima [A]  time = 1.48167, size = 177, normalized size = 2.16 \begin{align*} \frac{\frac{2 \, a b \log \left (b \tan \left (d x + c\right ) + a\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac{a b \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac{{\left (a^{2} - b^{2}\right )}{\left (d x + c\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac{b}{a^{3} + a b^{2} +{\left (a^{2} b + b^{3}\right )} \tan \left (d x + c\right )}}{d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(1/(a+b*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

(2*a*b*log(b*tan(d*x + c) + a)/(a^4 + 2*a^2*b^2 + b^4) - a*b*log(tan(d*x + c)^2 + 1)/(a^4 + 2*a^2*b^2 + b^4) +
 (a^2 - b^2)*(d*x + c)/(a^4 + 2*a^2*b^2 + b^4) - b/(a^3 + a*b^2 + (a^2*b + b^3)*tan(d*x + c)))/d

________________________________________________________________________________________

Fricas [A]  time = 1.92869, size = 336, normalized size = 4.1 \begin{align*} -\frac{b^{3} -{\left (a^{3} - a b^{2}\right )} d x -{\left (a b^{2} \tan \left (d x + c\right ) + a^{2} b\right )} \log \left (\frac{b^{2} \tan \left (d x + c\right )^{2} + 2 \, a b \tan \left (d x + c\right ) + a^{2}}{\tan \left (d x + c\right )^{2} + 1}\right ) -{\left (a b^{2} +{\left (a^{2} b - b^{3}\right )} d x\right )} \tan \left (d x + c\right )}{{\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )} d \tan \left (d x + c\right ) +{\left (a^{5} + 2 \, a^{3} b^{2} + a b^{4}\right )} d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(1/(a+b*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

-(b^3 - (a^3 - a*b^2)*d*x - (a*b^2*tan(d*x + c) + a^2*b)*log((b^2*tan(d*x + c)^2 + 2*a*b*tan(d*x + c) + a^2)/(
tan(d*x + c)^2 + 1)) - (a*b^2 + (a^2*b - b^3)*d*x)*tan(d*x + c))/((a^4*b + 2*a^2*b^3 + b^5)*d*tan(d*x + c) + (
a^5 + 2*a^3*b^2 + a*b^4)*d)

________________________________________________________________________________________

Sympy [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: AttributeError} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(1/(a+b*tan(d*x+c))**2,x)

[Out]

Exception raised: AttributeError

________________________________________________________________________________________

Giac [A]  time = 1.16124, size = 215, normalized size = 2.62 \begin{align*} \frac{\frac{2 \, a b^{2} \log \left ({\left | b \tan \left (d x + c\right ) + a \right |}\right )}{a^{4} b + 2 \, a^{2} b^{3} + b^{5}} - \frac{a b \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac{{\left (a^{2} - b^{2}\right )}{\left (d x + c\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac{2 \, a b^{2} \tan \left (d x + c\right ) + 3 \, a^{2} b + b^{3}}{{\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}{\left (b \tan \left (d x + c\right ) + a\right )}}}{d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(1/(a+b*tan(d*x+c))^2,x, algorithm="giac")

[Out]

(2*a*b^2*log(abs(b*tan(d*x + c) + a))/(a^4*b + 2*a^2*b^3 + b^5) - a*b*log(tan(d*x + c)^2 + 1)/(a^4 + 2*a^2*b^2
 + b^4) + (a^2 - b^2)*(d*x + c)/(a^4 + 2*a^2*b^2 + b^4) - (2*a*b^2*tan(d*x + c) + 3*a^2*b + b^3)/((a^4 + 2*a^2
*b^2 + b^4)*(b*tan(d*x + c) + a)))/d